package org.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//       浏览器终端方式
        PrintWriter out = resp.getWriter();
        out.println("hello,servlet");
        out.flush();
        out.close();
//        重定向方式
//        resp.sendRedirect("test1.jsp");

//        转发方式
//        RequestDispatcher requestDispatcher = req.getRequestDispatcher("test1.jsp");
//        requestDispatcher.forward(req,resp);
    }
}
